package com.example.web1012.controller;

import com.example.web1012.Dao.square;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @projectName: web10-12
 * @package: com.example.web1012.controller
 * @className: squreArea
 * @author: Berry Peng
 * @description: 作业。
 * @date: 2022/10/12 08:52
 * @version: 1.0
 */
@RestController
@RequestMapping("/squareArea")
public class squareArea {
    
    
    //计算五个的面积（参数为List）
    @RequestMapping(value = "/computeAreaByList",method = RequestMethod.POST)
    public List<square> computeAreaByList(@RequestBody List<square> squares){
        return squares;
    }
    
    
    //计算五个的面积（参数为数组）
    @RequestMapping(value = "/computeAreaByArr",method = RequestMethod.POST)
    @ResponseBody
    public square[] computeAreaByList(@RequestBody square[] squares){
        return squares;
    }
    
    //计算一个的面积（get方式，map方式）
    @RequestMapping(value = "/computeArea",method = RequestMethod.GET)
    public square computeArea(@RequestParam(name = "height")int height,@RequestParam(name = "weight")int weight,@RequestParam(name = "name")String name){
        return new square(name,height,weight);
    }
    
    //计算一个的面积（post方式，参数为对象）
    @RequestMapping(value = "/computeArea",method = RequestMethod.POST)
    @ResponseBody
    public square computeArea(@RequestBody square square){
        return square;
    }
}
